package com.yuehuanghun.admin.core.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import lombok.Data;

/**
 * 读取系统相关配置
 * 
 * @author yuehuanghun
 */
@Component
@ConfigurationProperties(prefix = "system")
@Data
public class SystemProperties {
	/** 项目名称 */
	private String name;

	/** 版本 */
	private String version;

	/** 版权年份 */
	private String copyrightYear;

	/** 实例演示开关 */
	private boolean demoEnabled;

	/** 上传路径 */
	private static String profile;

	/** 获取地址开关 */
	private static boolean addressEnabled;
	
	private static String TEMP_DIR = System.getProperty("java.io.tmpdir");
	
	private static String privateKey;

	public static String getProfile() {
		return profile;
	}

	public void setProfile(String profile) {
		SystemProperties.profile = profile;
	}

	public static boolean isAddressEnabled() {
		return addressEnabled;
	}

	public void setAddressEnabled(boolean addressEnabled) {
		SystemProperties.addressEnabled = addressEnabled;
	}

	/**
	 * 获取头像上传路径
	 */
	public static String getAvatarPath() {
		return getProfile() + "/avatar";
	}

	/**
	 * 获取下载路径
	 */
	public static String getDownloadPath() { //放到临时目录，避免文件堆积
		return TEMP_DIR + "/download/";
	}

	/**
	 * 获取上传路径
	 */
	public static String getUploadPath() {
		return getProfile() + "/upload";
	}

	public static String getPrivateKey() {
		return privateKey;
	}

	public void setPrivateKey(String privateKey) {
		SystemProperties.privateKey = privateKey;
	}
}